package main

import (
    "fmt"
    "io/ioutil"
    "net/http"
    "strings"
)

var chttp = http.NewServeMux()

func main() {

    chttp.Handle("/", http.FileServer(http.Dir("./dist/")))

    http.HandleFunc("/", HomeHandler) // homepage
    http.ListenAndServe(":8082", nil)
}

func check(e error) {
    if e != nil {
        panic(e)
    }
}
func HomeHandler(w http.ResponseWriter, r *http.Request) {
    dat, err := ioutil.ReadFile("./dist/index.html")
    check(err)
    if strings.Contains(r.URL.Path, ".") {
        chttp.ServeHTTP(w, r)
    } else {
        fmt.Fprintf(w, string(dat))
    }
}
